#!/bin/bash
clear

[[ "$EUID" -ne 0 ]] && echo "Script need to be run with root!"; exit 1

function helper() {
    echo
    echo "=============================== [ SSHD & OVPN ]"
    echo "[01] trial          - Buat trial akaun untuk dropbear & openvpn"
    echo "[02] create         - Buat akaun pengguna untuk dropbear & openvpn"
    echo "[03] active         - Memperbaharui tarikh luput akaun pengguna"
    echo "[04] password       - Ganti kata laluan akaun pengguna"
    echo "[05] login          - Senaraikan pengguna yang log masuk"
    echo "[06] lists          - Senaraikan semua akaun pengguna"
    echo "[07] lock           - Kunci atau nyahdayakan akaun pengguna"
    echo "[08] unlock         - Buka kunci atau dayakan akaun pengguna"
    echo "[09] delete         - Padamkan akaun pelanggan"
    echo "================================== [ SERVICES ]"
    echo "[10] dropbear       - Dropbear package service menu"
    echo "[11] openvpn        - OpenVPN package service menu"
    echo "[12] squid          - Squid3 package service menu"
    echo "[13] stunnel        - Stunnel4 package service menu"
    echo "==================================== [ SERVER ]"
    echo "[14] detail         - Tunjukkan perincian server"
    echo "[15] restore        - Buat pemulihan untuk server"
    echo "[16] backup         - Buat sandaran fail untuk server"
    echo "[17] speedtest      - Menguji kelajuan server"
    echo "-----------------------------------------------"
    echo "[00] quit           - Keluar dari menu"
    echo "-----------------------------------------------"
    echo "Copyright 2021 Cybertize, Allright Reserved."
    echo "==============================================="
    echo
}

read -p "Sila masukkan pilihan anda [00-17]: " CHOICE
if [[ "$CHOICE" = "" ]]; then
    helper
fi
case $CHOICE in
    01|trial )
        bash /usr/local/plugins/trial
    ;;
    02|create )
        bash /usr/local/plugins/create
    ;;
    03|active )
        bash /usr/local/plugins/active
    ;;
    04|password )
        bash /usr/local/plugins/password
    ;;
    05|login )
        bash /usr/local/plugins/login
    ;;
    06|lists )
        bash /usr/local/plugins/lists
    ;;
    07|lock )
        bash /usr/local/plugins/lock
    ;;
    08|unlock )
        bash /usr/local/plugins/unlock
    ;;
    09|delete )
        bash /usr/local/plugins/delete
    ;;
    10|dropbear )
        bash /usr/local/plugins/dropbear
    ;;
    11|openvpn )
        bash /usr/local/plugins/openvpn
    ;;
    12|squid )
        bash /usr/local/plugins/squid
    ;;
    13|stunnel )
        bash /usr/local/plugins/stunnel
    ;;
    14|detail )
        bash /usr/local/plugins/detail
    ;;
    15|restore )
        bash /usr/local/plugins/restore
    ;;
    16|backup )
        bash /usr/local/plugins/backup
    ;;
    17|speedtest )
        bash /usr/local/plugins/speedtest
    ;;
    *|help )
        helper
    ;;
    00|quit )
        exit 0
    ;;
esac
